Function Validate_OpenFileName (fn As String, fqual As String) As Integer
Dim temp As String
Dim pqual As String
Dim OldPath As String
Dim FileNotFound As Integer
Dim FirstCheck As Integer
On Error GoTo OpenFileNameError
Validate_OpenFileName = False
OldPath = FilesList.Path
SplitFileName fn, pqual, fqual
' first assign any path change entered
If pqual <> "" Then FilesList.Path = pqual
' now check the the file name
' if it exists already a dblclick will be generated in
' the files list control otherwise a file error will be
' generated (i.e. file not found, bad file name )
FileNotFound = False
FirstCheck = True
FilesList.FileName = "*."
FilesList.FileName = fqual
If FileNotFound Then
FirstCheck = False
FilesList.FileName = "*."
fqual = fqual + App_FileExtension
FilesList.FileName = fqual
Else
If AppOpenSave.Visible Then
'
' must have been a directory or pattern change only so update dir. list
'
RefreshDirectoriesList
If InStr(fqual, "*") = 0 And InStr(fqual, "?") = 0 Then
FilesList.Pattern = "*" + App_FileExtension
End If
FileName.Text = FilesList.Pattern
FileName.SelStart = 0
FileName.SelLength = 0
FileName.SetFocus
End If
End If
Exit_OpenFunction:
On Error GoTo 0
Exit Function
OpenFileNameError:
f$ = FilesList.Path
If Right$(f$, 1) <> "\" Then f$ = f$ + "\"
f$ = f$ + fqual
Select Case Err
Case FILE_NOT_FOUND
If FirstCheck And InStr(fqual, ".") = 0 Then
FileNotFound = True
Resume Next
End If
e$ = "Cannot find " + UCase$(f$) + CRLF + CRLF + "check to ensure that the path and file are correct."
Case PATH_NOT_FOUND
e$ = "Directory does not exist;" + CRLF + CRLF + "check to ensure you specified the correct directory."
Case Else
e$ = Error$(Err) + ";" + CRLF + CRLF + "check to ensure the filename has no more than 8 characters followed by a period and a 3-letter extension." + CRLF + CRLF + "No spaces, commas, or backslashes (/) are allowed."
End Select
FilesList.Path = OldPath
FilesList.Pattern = "*" + App_FileExtension
Beep
MsgBox e$, MB_ICONEXCLAMATION, APP_NAME
Resume Exit_OpenFunction
End Function
Function Validate_SaveFileName (fn As String, fqual As String) As Integer
Dim temp As String
Dim pqual As String
Dim OldPath As String
On Error GoTo SaveFileNameError
Validate_SaveFileName = False
OldPath = FilesList.Path
SplitFileName fn, pqual, fqual
' first assign any path change entered
If pqual <> "" Then FilesList.Path = pqual
' now check the the file name portion
If fqual <> "" Then
If Not CheckFileQual(fqual) Then Error 64
'
' if it exists already a dblclick will be generated in
' the files list control otherwise a file error will be
' generated (i.e. file not found, bad file name )
'
SaveDuplicate = False
FilesList.FileName = "*."
FilesList.FileName = fqual
If SaveDuplicate Then Validate_SaveFileName = True
Else
'
' directory change
'
RefreshDirectoriesList
FileName.Text = ""
FileName.SetFocus
End If
Exit_SaveFunction:
On Error GoTo 0
Exit Function
SaveFileNameError:
If Err <> FILE_NOT_FOUND Then
Beep
Select Case Err
Case PATH_NOT_FOUND
e$ = "Directory does not exist;" + CRLF + CRLF + "check to ensure you specified the correct directory."
Case Else
e$ = Error$(Err) + ";" + CRLF + CRLF + "check to ensure the filename has no more than 8 characters followed by a period and a 3-letter extension." + CRLF + CRLF + "No spaces, commas, or backslashes (/) are allowed."